package org.hxzon.workeasy.pages.contacts;

import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.hxzon.workeasy.model.EasyContacts;
import org.hxzon.workeasy.pages.base.MyBasePage;
import org.hxzon.workeasy.service.EasyContactsService;

public class CreateContacts extends MyBasePage {

    @Inject
    private EasyContactsService contactsSer;
    @Property
    private EasyContacts contacts;
    @InjectPage
    private ListContacts listContacts;

    @OnEvent(value = EventConstants.ACTIVATE)
    Object init() {
        contacts = new EasyContacts();
        return null;
    }

    @OnEvent(component = "add")
    Object add() {
        contactsSer.save(contacts);
        return listContacts;
    }
}
